Repository navigation
Add an option to turn off the inbound WebSocket server - #238
Merged
Merged
Conversation
A client that dials one configured server with connect_to() must not be reachable by any other server. accept_inbound_connections = false skips the WebSocket server; connect_to() works as before. The default keeps the server on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Documentation still incorrectly describes server_max_connections as unused when inbound connections are disabled and promises startup listening without accounting for accept_inbound_connections.
2 open issues
What changed in this PR
Adds an outbound-only mode to SendspinClient, allowing applications to disable the inbound WebSocket server while continuing to connect through connect_to(). Existing behavior remains the default.
Changes:
- Adds the default-enabled
accept_inbound_connectionsconfiguration option. - Skips WebSocket server creation when the option is disabled.
- Documents the option and adds lifecycle coverage for inbound listening and outbound dialing.
| File | Description |
|---|---|
tests/test_client_lifecycle.cpp |
Tests enabled and disabled inbound listening while verifying outbound dialing. |
src/connection_manager.cpp |
Makes WebSocket server creation conditional on the new option. |
include/sendspin/config.h |
Defines and documents the default-enabled configuration field. |
docs/integration-guide.md |
Documents outbound-only usage and the configuration option. |
Review effort: Balanced
server_max_connections still sizes the protocol task's accept slots, so only server_port is unused with accept_inbound_connections off. The start() descriptions now say that no server starts in that case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kahrendt
enabled auto-merge (squash)
November 4, 2026 14:49
kahrendt
added a commit
that referenced
this pull request
Nov 4, 2026
## Summary From the second coherence pass on the allocation follow-ups (Sendspin/backlog#92). The handshake logs peer text only up to 32 bytes, but after it three sites a connection keyed with the published Sentinel PSK reaches logged peer text at full length: up to 16 KiB per message, enough to stall the protocol task on a UART console. `determine_message_type()` also compared `type` as a `const char*`, so a type with an embedded NUL (`"server/hello\u0000x"`) dispatched as the known one. Separately, a present non-array `server/activate` `active_roles` was silently taken as omitted, keeping the prior roles, while its sibling `stream/*` `roles` rejects. ## Change - **Log bound:** `PEER_TEXT_LOG_BYTES` (32) and `peer_text_for_log()` (a UTF-8-safe cut) move from `noise_handshake.cpp` to `inline_text.h`. They bound the unhandled message `type`, an unrecognized enum value from `read_enum_field()` (server/activate's `pairing.method`/`pairing.format`), and the `pair/abort` reason. Every other peer string is bounded where it is parsed. - **Message type:** `determine_message_type()` reads `type` once as a `string_view` and compares with `==`. - **active_roles:** a present non-array value logs and rejects the activate, like `read_stream_roles()`; absent or null still keeps the prior set. A rejected activate leaves a nursery connection to the 30 s establish reap and an admitted one with its prior state. - **Docs:** `conventions.md` says peer text no field bounds is logged only up to the cap. - **Test port:** the inbound-off lifecycle test moves off 19105, which #238 and #241 both picked, so a parallel ctest run no longer fails one of them. ## Tests - `Protocol.DetermineMessageType` gains an embedded-NUL row; a `strcmp` comparison fails it. - `Protocol.ServerActivateReadsActiveRoles` gains null, string and object rows; restoring the nullopt fallback fails the string and object rows, dropping the null branch fails the null row. - `Protocol.UnrecognizedPeerTextIsLoggedOnlyUpToTheBound` (pairing method and pair/abort reason) and `EncryptedLifecycle.AnUnhandledTypeIsLoggedOnlyUpToTheBound` capture stderr and check 32 bytes are logged and 33 are not; dropping each cut fails its test. ## Not in this PR - A non-string entry in `activities`, `active_roles` or `stream/*` `roles` is still skipped, so `active_roles:[7]` on a connection that is not playback-capable passes the "MUST be empty" rule. - Because the pairing index is bumped only after a successful parse, a server that counts a parse-rejected pairing activate falls one index ahead until the next handshake.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
accept_inbound_connectionsto the client config. When off, the client runs no WebSocket server, andconnect_to()is the only way a server reaches it. A client that dials one configured server, such as an Axis speaker app, then cannot be reached or paired by any other server on the network. The default is unchanged.🤖 Generated with Claude Code